package zmm

import (
	"context"
	"github.com/tiger1103/gfast/v3/api/v1/zmm"
	"github.com/tiger1103/gfast/v3/internal/app/system/controller"
	"github.com/tiger1103/gfast/v3/internal/app/zmm/service"
)

var ZmmMember = zmmMemberController{}

type zmmMemberController struct {
	controller.BaseController
}

// List 列表
func (c *zmmMemberController) MemberList(ctx context.Context, req *zmm.ZmmMemberListReq) (res *zmm.ZmmMemberListRes, err error) {
	res = new(zmm.ZmmMemberListRes)
	res.Total, res.ZmmMember, err = service.ZmmMember().GetList(ctx, req)
	return
}

func (c *zmmMemberController) MemberEdit(ctx context.Context, req *zmm.ZmmMemberEditReq) (res *zmm.ZmmMemberEditRes, err error) {
	res = new(zmm.ZmmMemberEditRes)
	_, err = service.ZmmMember().Edit(ctx, req)
	if err != nil {
		return nil, err
	}
	return
}

func (c *zmmMemberController) MemberDelete(ctx context.Context, req *zmm.ZmmMemberDelReq) (res *zmm.ZmmMemberDelRes, err error) {
	res = new(zmm.ZmmMemberDelRes)
	err = service.ZmmMember().Delete(ctx, req)
	return
}

func (c *zmmMemberController) Recharge(ctx context.Context, req *zmm.ZmmMemberRechargeReq) (res *zmm.ZmmMemberRechargeRes, err error) {
	res = new(zmm.ZmmMemberRechargeRes)
	err = service.ZmmMember().Recharge(ctx, req)
	return
}

func (c *zmmMemberController) MemberOpQueryList(ctx context.Context, req *zmm.ZmmMemberOpQueryListReq) (res *zmm.ZmmMemberListRes, err error) {
	res = new(zmm.ZmmMemberListRes)
	res.ZmmMember, err = service.ZmmMember().GetOpQuery(ctx, req)
	return
}
